package ru.spb.osll.myfit.util;

import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

@SuppressWarnings("unchecked")
public class ReflectionUtils {
	private static final List<Class<?>> primitiveTypes = CollectionUtils.list(
			Integer.TYPE, Long.TYPE, Double.TYPE, Float.TYPE, Boolean.TYPE,
			Character.TYPE, Byte.TYPE, Void.TYPE, Short.TYPE);
	
	private static final List<Class<?>> primitiveTypeWrappers = CollectionUtils.list(
			Integer.class, Long.class, Double.class, Float.class, Boolean.class,
			Character.class, Byte.class, Void.class, Short.class);
	
	public static final Map<Class<?>, Class<?>> primitiveTypeWrappersMap = CollectionUtils.map(primitiveTypes, primitiveTypeWrappers);
	
	public static Set<String> getClassHierarhy(Class<?> clazz) {
		HashSet<String> res = new HashSet<String>();
		res.add(clazz.getName());
		Class<?> superclass = clazz.getSuperclass();
		
		while(superclass != null) {
			res.add(superclass.getName());
			superclass = superclass.getSuperclass();
		}
		
		return res;
	}

}
